import $api from "./request.js"

//获取用户认养列表信息
export const getFosterList = ()=>$api({
	url:"/ryTenancy/getFosterList",
	method:"GET",
})
//获取所有认养地信息
export const findAllBase = ()=>$api({
	url:"/ryLand/findAllLandAndLeaseState",
	method:"GET",
})
//根据认养地id获取该地地块信息
export const findPlantByLanId = (query)=>$api({
	url:'/ryLand/findPlantByLanId?'+query,
	method:"GET",
})
//根据地块id计算地块价格
export const findRentsByPlantS = (ids)=>$api({
	url:'/ryTenancy/findRentsByPlantS',
	data:ids,
})
//base64转换为图片
export const uploadBase64Oss = (base64)=>$api({
	url:'/foster/file/uploadBase64Server',
	data:base64,
	header:{
		'Content-Type':'application/x-www-form-urlencoded'
	}
})
//保存租地表单配置
export const insertTenancy = (data)=>$api({
	url:'/ryTenancy/insertTenancy',
	data,
})
//微信登录
export const weiXinLogin = (code) =>$api({
	url:'/user/login?code='+code
})
//根据租地id获取租地订单信息
export const findTenancyOrderById = (query)=>$api({
	url:'/ryTenancy/findTenancyOrderById?tenancyId='+query,
	method:"GET",
})
//根据地块id和状态查询地块信息
export const findPlantSByPlantIdAndState = (query)=>$api({
	url:'/ryPlant/findPlantSByPlantIdAndState?'+query,
	method:'GET',
})
//根据种植id查询该种植的详情与任务列表
export const findPlantDetailByPlantId = (query)=>$api({
	url:'/ryPlant/findPlantDetailByPlantId?'+query,
	method:"GET"
})
//根据地块id获取该地块种植种类
export const findLandGrowVariety = (query)=>$api({
	url:'/ryLand/findLandGrowVariety?'+query,
	method:'GET'
})
//种植
export const landGrow = (data)=>$api({
	url:'/ryLand/landGrow',
	data
})
//新增任务
export const addTask = (data)=>$api({
	url:'/ryTask/addTask',
	data
})
//根据品种id获取任务类型
export const findAllFarmOperation = (query)=>$api({
	url:'/ryTask/findAllFarmOperation?'+query,
	method:'GET'
})
//查询所有施肥投入品的道具
export const findVariableInputDetailByType = (query)=>$api({
	url:'/ryRyTask/findVariableInputDetailByType?'+query,
	method:"GET"
})
//通过任务类型查询该地块任务次数
/**
 * @param landMsgId {string}
 * @param taskType {string}
*/
export const findTaskNumberByTaskType = (query)=>$api({
	url:'/ryTask/findTaskNumberByTaskType?'+query,
	method:'GET'
})
/**
 * @description 通过小地块id查询当前小地块任务列表
 * @@param {string} landMsgId 
*/
export const taskList = (query)=>$api({
	url:'/ryTask/taskList?'+query,
	method:'GET'
})
/**
 * @description 通过任务id获取任务详情
 * @param {string} id
**/
export const findTaskDetailById = (query)=>$api({
	url:'/ryTask/findTaskDetailById?'+query,
	method:'GET'
})
/**
 * @description 查询当前用户的所有地址
*/
export const getUserAllAddress = ()=>$api({
	url:'/ryUserAddress/page',
	method:"GET"
})

/**
 * @description 获取当前账号邮寄信息
   @param landMsgId {string}
*/
export const findMailGoodsInfo = (query)=>$api({
	url:'/ryPlant/findMailGoodsInfo?'+query,
	method:'GET'
})

/**
 * @description 发送邮寄请求
   @param landMsgId {string}
   @param addressId {string}
*/
export const mailGoods = (query)=>$api({
	url:'/ryLand/mailGoods?'+query,
})

/**
 * @description 新增/修改收货地址
*/
export const addOrEditAddress = data =>$api({
	url:'/ryUserAddress',
	data
})
/**
 * @description 删除收货地址
*/
export const delAddress = query =>$api({
	url:'/ryUserAddress/'+query,
	method:"DELETE"
})
/**
 * @description 支付接口
*/
export const pay = (query)=>$api({
	url:'/wxPay/pay?orderNo='+query,
})

/**
 * @description 查询用户合同列表
 */
export const findUserContract = ()=>$api({
	url:'/ryTenancy/findUserContract',
	method:"GET"
})

/**
 * @description 根据id获取合同详情
 * @param {string}  = [tenancyId] 
*/
export const findContract = query=>$api({
	url:'/ryTenancy/findContract?'+query,
	method:'GET'
})
/**
 * @description 根据地块id获取天气
 * @param {string}  = [landId] 
*/
export const findWeatherAndCameraDataByLandId = query =>$api({
	url:'/ryLand/findWeatherAndCameraDataByLandId?'+query,
	method:"GET"
})
/**
 * @description 获取订单列表
 * @param {number}  = [pageNum] 
 * @param {number}  = [pageSize] 
 * @param {number}  = [state]
*/
export const findUserOrderInfo = query =>$api({
	url:'/ryTenancy/findUserOrderInfo?'+query,
	method:"GET"
})

export const findOutGoodsBatchByPlantId = query =>$api({
	url:'/ryLand/findOutGoodsBatchByPlantId?'+query,
	method:"GET"
})




////** 上传图片接口 **////
export const uploadImage = (data)=>{
	let promise =  new Promise((reslove,reject)=>{
		uni.uploadFile({
			url:'https://bbgy.cpzsyun.com:82/ryapi/gardenFoster/file/uploadImg',
			filePath:data,
			name:"file",
			header:{
				'Content-Type':'multipart/form-data; boundary=--------------------------847724091307819899995715',
			},
			success: (res) => {
				reslove(res)
			},
			fail: (err) => {
				reject(err)
			}
		})
	})
	return promise
}




////**  操作端接口  **////
/**
 * @description 操作端登录
 * @param {object}:{
			 name:{string}
			 pwd:{string}
		   } 
*/
export const operatorLogin = (data)=>$api({
	url:'/ryOperateAccount/login',
	data
})
// 操作端根据状态获取任务列表
export const findTaskByUserId = (query)=>$api({
	url:'/opRyTask/findTaskByUserId?'+query,
	method:'GET',
	header:{
		token:uni.getStorageSync("operatorAccount").token
	}
})
//根据地块id和任务id获取该地块的指定任务的任务详情
export const operatorFindTaskDetailById = (query)=>$api({
	url:'/opRyTask/findTaskDetailById?'+query,
	method:'GET',
	header:{
		token:uni.getStorageSync("operatorAccount").token
	}
})
//操作端处理任务
export const disposeTask = (data)=>$api({
	url:'/opRyTask/disposeTask',
	data,
	header:{
		token:uni.getStorageSync("operatorAccount").token
	}
})
//操作端扫描二维码获取地块id查询详情
export const findPlantByScanPlantId = query =>$api({
	url:'/opRyTask/findPlantByScanPlantId?'+query,
	method:'GET',
	header:{
		token:uni.getStorageSync("operatorAccount").token
	}
})

//操作端查询所有农事操作
export const getAllOperatorAction = query =>$api({
	url:'/opRyTask/findAllFarmOperation?'+query,
	method:"GET",
	header:{
		token:uni.getStorageSync("operatorAccount").token
	}
})
//查询所有施肥投入品的道具
export const getInputItem = (query)=>$api({
	url:'/opRyTask/findVariableInputDetailByType?'+query,
	method:"GET",
	header:{
		token:uni.getStorageSync("operatorAccount").token
	}
})
// //操作端根据地块id获取当前品种列表
// export const findVarietyByLandId = query =>$api({
// 	url:'/opRyTask/findVarietyByLandId?'+query,
// 	method:'GET',
// 	header:{
// 		token:uni.getStorageSync("operatorAccount").token
// 	}
// })
// //操作端根据品种类型获取任务类型
// export const findOperatorByVarietyName = query =>$api({
// 	url:'/opRyTask/findOperatorByVarietyName?'+query,
// 	method:'GET',
// 	header:{
// 		token:uni.getStorageSync("operatorAccount").token
// 	}
// })
//操作端根据地块id获取地块坐标
export const opFindTaskDetailById = (query)=>$api({
	url:'/opRyTask/findTaskDetailById?'+query,
	method:'GET',
	header:{
		token:uni.getStorageSync("operatorAccount").token
	}
})
//操作端获取任务完成次数
export const getTaskFinishCount = (query)=>$api({
	url:'/opRyTask/findTaskNumberByTaskType?'+query,
	method:'GET',
	header:{
		token:uni.getStorageSync("operatorAccount").token
	}
})
//管理员新增任务
export const addOperatorTask = (data)=>$api({
	url:'/opRyTask/addOperatorTask',
	data,
	header:{
		token:uni.getStorageSync("operatorAccount").token
	}
})
//根据当前管理员账号查询可操作的基地信息或可操作基地下的地块信息
export const findOperatorBaseAndLand = query =>$api({
	url:'/opRyTask/findOperatorBaseAndLand?'+query,
	method:"GET",
	header:{
		token:uni.getStorageSync("operatorAccount").token
	}
})
//根据地块id查询地图坐标与地块绑定的信息
export const findLandInfoByLandId = query => $api({
	url:'/opRyTask/findLandInfoByLandId?'+query,
	method:'GET',
	header:{
		token:uni.getStorageSync("operatorAccount").token
	}
})